﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace XM
{
    public class DBhleper
    {

        static string lj = "Data Source=.;Initial Catalog=movie;Integrated Security=True";
        public static int write(string sql)
        {
            SqlConnection coon = new SqlConnection(lj);
            coon.Open();
            SqlCommand cmd = new SqlCommand(sql, coon);
            int rs = cmd.ExecuteNonQuery();
            coon.Close();
            return rs;
        }
        public static DataTable read(string sql)
        {
            SqlConnection coon = new SqlConnection(lj);
            coon.Open();
            SqlCommand cmd = new SqlCommand(sql, coon);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            DataTable table = new DataTable();
            adp.Fill(table);
            coon.Close();
            return table;

    }
    }
}
